<template>
  <div class="answer">
    <component :is="currentComponent" :data="qnData"></component>
  </div>
</template>

<script setup lang="ts">
import { defineAsyncComponent, ref } from 'vue'
import { useRoute } from 'vue-router'

const platform = navigator.platform
const win = platform.indexOf('Win') == 0
const mac = platform.indexOf('Mac') == 0
const xll = platform == 'Xll' || platform.indexOf('Linux') == 0
let device = win || mac || xll ? 'Pc' : 'Phone'
const route = useRoute()
const id = route.params.id
if (route.query.pc) {
  device = 'Pc'
} else if (route.query.phone) {
  device = 'Phone'
}

const qnData = ref()
qnData.value = JSON.parse(localStorage.getItem('qnJSON') || '{}')

const currentComponent = defineAsyncComponent(() => import(`./${device}.vue`))
</script>

<style scoped></style>
